import { createRouter, createWebHashHistory } from "vue-router";
//登陆模块
import LoginView from "../views/login/LoginView.vue";
import ForgetView from "../views/login/ForgetView.vue";
import ResetPasswordView from "../views/login/ResetPasswordView.vue";

import MainFrameView from "../views/frame/MainFrameView.vue";
//用户管理
import UserManagment from "../views/userManagment/UserManagmentView.vue";
import AdminManagment from "../views/userManagment/AdminManagmentView.vue";
import roleManangment from "../views/userManagment/RoleView.vue"
import Home from "../views/home/Home1.vue"
//数据分析
import DataAnalysis from "../views/main/DataAnalysisView.vue";
import Data from "../views/main/Data2.vue";
//车位管理
import ParkingSpace from "../views/main/ParkingSpaceView.vue";
import AreaView from "../views/main/AreaView.vue"
import RecordView from "../views/main/RecordView.vue"
//车辆管理
import CategoryView from "../views/car/CarCategoryView.vue"
import CarList from "../views/car/CarList.vue"
import VolationList from "../views/car/VolationList.vue"

//日志管理
import LoginLog from "../views/log/LoginLog.vue"
import OptionLog from "../views/log/OperationLog.vue"

//学员管理
import UniversityView from "../views/univer/UniversityView.vue"
import CollegeView from "../views/univer/CollegeView.vue"
import CollegeDetail from "../views/univer/CollegeDetail.vue"





let routes = [
  {
    path: "/",
    name: "总的开始页面",
    show: false,
    // component: Data,
    component: () => import('../views/login/LoginForget.vue'),
  },
  {
    path: "/login",
    name: "登陆页面",
    show: false,
    component: LoginView,
  },
  {
    path: "/forgetPassword",
    name: "注册页面",
    show: false,
    component: ForgetView,
  },
  {
    path: "/resetPassword",
    name: "重置密码页面",
    show: false,
    component: ResetPasswordView,
  },
  {
    path: "/:catchAll(.*)",
    name: "404",
    show: false,
    component: () => import('../views/except/NotFound.vue'),
  },
  {
    path: "/:pathMatch(.*)*",
    name: "401",
    show: false,
    component: () => import('../views/except/NoAuthorization.vue'),
  },
  {
    path: "/server-error",
    name: "500",
    show: false,
    component: () => import('../views/except/500Error.vue'),
  },
  {
    path: "/noData",
    name: "noData",
    show: false,
    component: () => import('../views/except/NoData.vue'),
  },
  {
    path: "/mainFrame",
    component: MainFrameView,
    name: "首页",
    show1: true,
    show2: true,
    redirect: '/dataAnalysis',
    icon: 'iconfont icon-shouye',
    children: [
      {
        path: "/shouye",
        name: "首页",
        icon: 'iconfont icon-shouye',
        show1: true,
        show2: false,
        component: Home,
      }
    ]
  },
  {
    path: "/mainFrame",
    component: MainFrameView,
    name: "学院管理",
    show1: true,
    show2: true,
    icon: 'iconfont icon-dianshangxueyuan',
    children: [
      {
        path: "/university",
        name: "学校模块",
        icon: 'iconfont icon-xuexiao',
        show1: true,
        show2: false,
        component: UniversityView,
      },
      {
        path: "/collegeView",
        name: "学院模块",
        icon: 'iconfont icon-iccollegegraduate',
        show1: true,
        show2: true,
        component: CollegeView,
      },
      {
        path: "/collegeDetail",
        name: "学院详情",
        icon: 'iconfont icon-xiangqing',
        show1: true,
        show2: true,
        component: CollegeDetail,
      },
    ]
  },
  {
    path: "/mainFrame",
    component: MainFrameView,
    name: "用户管理",
    show1: true,
    show2: true,
    icon: 'iconfont icon-yonghuguanli',
    children: [
      {
        path: "/admin",
        name: "管理员模块",
        icon: 'iconfont icon-qiyeguanli_yuangongguanli',
        show1: true,
        show2: true,
        component: AdminManagment,
      },
      {
        path: "/userManagment",
        name: "普通用户模块",
        icon: 'iconfont icon-xueshengguanli',
        show1: true,
        show2: true,
        component: UserManagment,
      },
      {
        path: "/roleManangment",
        name: "角色管理",
        icon: 'iconfont icon-xiangqing',
        show1: true,
        show2: false,
        component: roleManangment,
      },
    ]
  },
  {
    path: "/mainFrame",
    component: MainFrameView,
    name: "车辆管理",
    icon: 'iconfont icon-cheliangguanli',
    show1: true,
    show2: true,
    children: [
      {
        path: "/categoryView",
        name: "车辆类型",
        icon: 'iconfont icon-cheliangleixing',
        show1: true,
        show2: true,
        component: CategoryView,
      },
      {
        path: "/carList",
        name: "所有车辆",
        icon: 'iconfont icon-menu_clxx',
        show1: true,
        show2: true,
        component: CarList,
      },
      {
        path: "/volationList",
        name: "违规管理",
        icon: 'ivconfont icon-a-cheliangweizhangjilu2',
        show1: true,
        show2: true,
        component: VolationList,
      },
    ]
  },
  {
    path: "/mainFrame",
    component: MainFrameView,
    name: "车库管理",
    icon: 'iconfont icon-tingchechangguanli',
    show1: true,
    show2: true,
    children: [
      {
        path: "/parkingSpace",
        name: "所有车位",
        icon: 'iconfont icon-tingchewei',
        show1: true,
        show2: true,
        component: ParkingSpace,
      },
      {
        path: "/areaView",
        name: "所有停车场",
        icon: 'iconfont icon-tingchechang',
        show1: true,
        show2: true,
        component: AreaView,
      },
      {
        path: "/recordView",
        name: "停车记录",
        icon: 'iconfont icon-iconfontzhizuobiaozhun023141',
        show1: true,
        show2: true,
        component: RecordView,
      },
    ]
  },
  {
    path: "/mainFrame",
    component: MainFrameView,
    name: "数据分析",
    icon: 'iconfont icon-beikongshuiwupingtaimenhu-tubiao_dashujufenxigongju',
    show1: true,
    show2: true,
    children: [
      {
        path: "/dataAnalysis",
        name: "数据分析",
        icon: 'iconfont icon-shujufenxi',
        show1: true,
        show2: true,
        component:  Data,
      },
    ]
  },
  {
    path: "/mainFrame",
    component: MainFrameView,
    name: "日志管理",
    icon: 'iconfont icon-rizhiguanli',
    show1: true,
    show2: true,
    children: [
      {
        path: "/loginLog",
        name: "登陆日志",
        icon: 'iconfont icon-denglurizhi',
        show1: true,
        show2: true,
        component: LoginLog,
      },
      {
        path: "/optionLog",
        name: "操作日志",
        icon: 'iconfont icon-caozuorizhi',
        show1: true,
        show2: true,
        component: OptionLog,
      },
    ]
  },
];
// 在应用初始化时，将路由信息存储到 localStorage
// store.dispatch('saveRoutes', routes);
localStorage.setItem('routes', JSON.stringify(routes));
// 从 localStorage 中读取路由信息
// 创建计算属性来映射存储在 Vuex store 中的路由信息
// const computed = {
//   ...mapState('routes1', ['routes']) // 替换 'router' 为您实际的模块命名空间
// };
const storedRoutes = localStorage.getItem('routes');
// if(routes == null || routes == []){
//   routes = routes1
// }
// localStorage.setItem
// if(routes == null){
//   routes = storedRoutes
// }

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
